package com.atguigu.service;

import com.atguigu.mapper.AccountMapper;
import com.atguigu.pojo.Account;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountMapper accountMapper;

    @Override
    public void updateAccount(Account account) {
        accountMapper.updateAccount(account);
    }

    @Override
    public Account queryAccountById(Integer id) {
        return accountMapper.queryAccountById(id);
    }

    @Override
    public void saveAccount(Account account) {
        accountMapper.saveAccount(account);
    }

    @Override
    public void deleteAccountById(Integer id) {
        accountMapper.deleteAccountById(id);
    }

    @Override
    public PageInfo<Account> queryAccountByPage(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        List<Account> accountList = accountMapper.queryAccountByPage();

        return new PageInfo<Account>(accountList);
    }
}
